package com.voice.server.properties;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

@Data
@ConfigurationProperties(prefix = "filter")
public class FilterProperties implements InitializingBean {

    private Set<String> passUrl=new HashSet<>();

    private Set<String> freeUrl=new HashSet<>();

    private Map<String,String> authorityUrl=new ConcurrentHashMap<>();

    private Set<String> redirectUrl=new HashSet<>();

    @Override
    public void afterPropertiesSet() throws Exception {
        String string="/**/*/login," +
                "/**/*/password," +
                "/**/*/register," +
                "/**/*/send_code," +
                "/**/*.js*," +
                "/**/*.map*," +
                "/**/*.css*," +
                "/**/*.html*," +
                "/**/*.jpg*," +
                "/**/*.jpeg*," +
                "/**/*.jpeg*," +
                "/**/*.png*," +
                "/**/*.gif*," +
                "/**/*.ico*," +
                "/*.ico*," +
                "/**/*.woff*," +
                "/**/*.woff2*," +
                "/**/*.ttf*";
        for(String url:string.split(",")){
            freeUrl.add(url);
        }
    }
}
